
let http = require('http');
let fs = require('fs');

//创建服务器

let Server = http.createServer();
Server.on('request',function(req,res){
    res.setHeader("Content-type","text/html;charset=UTF-8");
    let url = req.url;
    if (url ==='/login'){
    
            let  readStream =  fs.createReadStream('readed2.txt')
            readStream.on('data',function(chuck){
            res.end(chuck.toString())
 })
    }
    else if (url ==='/index'){
        let  readStream =  fs.createReadStream('readed.txt');
        readStream.on('data',function(chuck){
        res.end(chuck.toString())
 })
    }
    else if (url === '/page'){
        let  readStream =  fs.createReadStream('readed3.txt');
        readStream.on('data',function(chuck){
        res.end(chuck.toString())
 })
    }
    else {
        res.end('404 not found')
    }

})

Server.listen(8080,function(){
    console.log("服务器已启动成功！");
})